const day = document.querySelector('.day');
const hour = document.querySelector('.hour');
const min = document.querySelector('.min');
const sec = document.querySelector('.sec');
const date = new Date();
console.log(date.getTime());
console.log(date.valueOf());
love(); //先调用一次防止页面刷新空白
const getLove = setInterval(love, 1000);

function love() {
    const date1 = +new Date();
    const date2 = +new Date('2020-9-01 00:00:00');
    console.log(date1);
    const times = date1 - date2;
    let d = parseInt(times / 1000 / 60 / 60 / 24);
    d = d < 10 ? '0' + d + '天' : d + '天';
    day.innerHTML = d;
    let h = parseInt(times / 1000 / 60 / 60 % 24);
    h = h < 10 ? '0' + h + '时' : h + '时';
    hour.innerHTML = h;
    let m = parseInt(times / 1000 / 60 % 60);
    m = m < 10 ? '0' + m + '分' : m + '分';
    min.innerHTML = m;
    let s = parseInt(times / 1000 % 60);
    s = s < 10 ? '0' + s + '秒' : s + '秒';
    sec.innerHTML = s;
    // 完成静态
}

